{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">附件管理</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
    </div>
</div>
<script type="text/html" id="picTpl">
  {{#  if(d.mime.indexOf("image") > -1){ }}
    <img style="max-width:80px; max-height:30px;" src="{{d.path}}" data-image="{{d.name}}">
  {{#  } else { }}
    <img style="max-width:80px; max-height:30px;" src="{:url('admin/ajax/icon')}?suffix={{d.ext}}">
  {{#  } }}
</script>
{/block}
{block name="script"}
<script>
layui.use('yznTable', function() {
    var table = layui.yznTable;

    var init = {
        delete_url: '{:url("del")}',
    };

    table.render({
        init: init,
        id: 'dataTable',
        toolbar: ['refresh','delete'],
        elem: '#dataTable',
        url: '{:url("index")}',
        cols: [
            [
                { type: 'checkbox', fixed: 'left' },
                { field: 'id', width: 80, title: 'ID', sort: true },
                { field: 'aid', width: 80, title: '用户',hide:true,addClass: "selectpage", extend: "data-source='admin/manager/index' data-field='username'" },
                { field: 'name', title: '名称', searchOp: 'like' },
                { field: 'path', width: 100, align: "center",title: '图片', search: false, templet: '#picTpl' },
                { field: 'path', width: 450, align: "center", title: '物理路径', templet: '<div><a class="layui-btn layui-btn layui-btn-xs" href="{{d.path}}" target="_blank">{{d.path}}</a></div>', searchOp: 'like' },
                { field: 'size', width: 100, title: '大小', sort: true },
                { field: 'ext', width: 100, title: '类型', searchOp: 'like' },
                { field: 'mime', width: 120, title: 'Mime类型' , searchOp: 'like'},
                { field: 'driver', width: 100, title: '存储引擎', searchOp: 'like' },
                { field: 'create_time', width: 180, title: '上传时间', search: 'range' },
                { width:60, title: '操作',templet: yznTable.formatter.tool,operat: ['delete']}
            ]
        ],
        page: {}
    });
});
</script>
{/block}